﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace XNAGame_Lab1
{
 public   class ReadXML
    {
        public string DisplayNode(XmlReader node)
        {
            
            switch (node.NodeType)
            {
                case XmlNodeType.Text:
                    return node.Value.ToString();
            }
            return "";
        }

        public List<string> AddElement(XmlReader reader)
        {
            List<string> menu = new List<string>();
            while (reader.Read())
            {
                if(DisplayNode(reader)!="")
                    menu.Add(DisplayNode(reader));
            }
            return menu;
        }
        public static void WriteXML()
        {
            XmlTextWriter writer = new XmlTextWriter("player.xml", null);

            /* Use indenting for readability */
            writer.Formatting = Formatting.Indented;
            writer.Indentation = 4;
            /* Now write out our XML document */
            writer.WriteStartDocument();
            writer.WriteStartElement("player");
            writer.WriteStartElement("Name");

            writer.WriteString("Albert");
            writer.WriteEndElement();

            writer.WriteStartElement("Level");
            writer.WriteString("100");
            writer.WriteEndElement();
            writer.WriteStartElement("HP");
            writer.WriteString("1000");
            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.WriteEndDocument();
    /* Don't forget to close the writer */
            writer.Close();
        }
    }
}
